package hot_100;

public class 对称二叉树 {
    public static void main(String[] args) {

    }

    public boolean isSymmetric(TreeNode root) {
        return root == null || slove(root.left, root.right);
    }

    public boolean slove(TreeNode lc, TreeNode rc) {
        if (lc == null && rc == null)
            return true;
        if (lc == null || rc == null || (lc.val != rc.val))
            return false;
        return slove(lc.right, rc.left) && slove(lc.left, rc.right);
    }

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
}
